Skip to content

Conversation

@brightsparc
Copy link

@brightsparc brightsparc commented Nov 12, 2025

This PR includes support for GrokModel which uses the xai-sdk-python library, which supports chat completion, tool calling, and built-in server side tool calls.

I have included a series of tests, as well as an example for a stock analysis agent that uses search and code execution, and returns results in the form of a local tool call.

python examples/pydantic_ai_examples/stock_analysis_agent.py

🔍 Starting stock analysis...

Query: Can you find me the best performing stock on the NASDAQ over the last week, and return the price project for the end of the year using a simple linear regression. 

17:02:12.318 stock_analysis_agent run
17:02:12.322   chat grok-4-fast
17:02:12.326     chat.sample grok-4-fast
17:03:17.348 Server-side web_search tool called
17:03:17.349 Server-side web_search tool called
17:03:17.350 Server-side web_search tool called
17:03:17.350 Server-side web_search tool called
17:03:17.350 Server-side web_search tool called
17:03:17.350 Server-side web_search tool called
17:03:17.351 Server-side web_search tool called
17:03:17.351 Server-side web_search tool called
17:03:17.351 Server-side web_search tool called
17:03:17.352 Server-side code_execution tool called
17:03:17.352 Server-side code_execution tool called
17:03:17.352 Server-side web_search tool called
17:03:17.352 Server-side code_execution tool called
17:03:17.353 Server-side web_search tool called
17:03:17.353 Server-side code_execution tool called

✅ Analysis complete!

🔧 Server-Side Tools Used:
   Web Search calls: 11
   Code Execution calls: 4

Stock: NVDA
Current Price: $181.36
Projected Year-End Price: $205.01

Analysis: NVIDIA (NVDA) was identified as a top-performing stock on NASDAQ based on recent analyses and picks for the week of November 17, 2025. Using simple linear regression on daily closing prices from January 1, 2025, to November 19, 2025, the model shows a strong upward trend with R² = 0.72. The projection to December 31, 2025, estimates a price of $205.01.

📈 Usage Statistics:
   Requests: 1
   Input Tokens: 0
   Output Tokens: 0
   Total Tokens: 0

Below is what the output looks like in logfire. It includes custom spans emmited from the xai-sdk.

image

@brightsparc brightsparc marked this pull request as draft November 12, 2025 01:04
@DouweM
Copy link
Collaborator

DouweM commented Nov 12, 2025

@brightsparc Thanks Julian! Let me know when this is ready for review or if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants